home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_whichdb.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  2KB  |  74 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. '''Test script for the whichdb module
  5.    based on test_anydbm.py
  6. '''
  7. import os
  8. import test.test_support as test
  9. import unittest
  10. import whichdb
  11. import anydbm
  12. import tempfile
  13. import glob
  14. _fname = test.test_support.TESTFN
  15.  
  16. def _delete_files():
  17.     for f in glob.glob(_fname + '*'):
  18.         
  19.         try:
  20.             os.unlink(f)
  21.         continue
  22.         except OSError:
  23.             continue
  24.         
  25.  
  26.     
  27.  
  28.  
  29. class WhichDBTestCase(unittest.TestCase):
  30.     
  31.     def __init__(self, *args):
  32.         unittest.TestCase.__init__(self, *args)
  33.  
  34.     
  35.     def tearDown(self):
  36.         _delete_files()
  37.  
  38.     
  39.     def setUp(self):
  40.         _delete_files()
  41.  
  42.  
  43. for name in anydbm._names:
  44.     
  45.     try:
  46.         mod = __import__(name)
  47.     except ImportError:
  48.         continue
  49.  
  50.     
  51.     def test_whichdb_name(self, name = name, mod = mod):
  52.         f = mod.open(_fname, 'c')
  53.         f.close()
  54.         self.assertEqual(name, whichdb.whichdb(_fname))
  55.         f = mod.open(_fname, 'w')
  56.         f['1'] = '1'
  57.         f.close()
  58.         self.assertEqual(name, whichdb.whichdb(_fname))
  59.  
  60.     setattr(WhichDBTestCase, 'test_whichdb_%s' % name, test_whichdb_name)
  61.  
  62.  
  63. def test_main():
  64.     
  65.     try:
  66.         test.test_support.run_unittest(WhichDBTestCase)
  67.     finally:
  68.         _delete_files()
  69.  
  70.  
  71. if __name__ == '__main__':
  72.     test_main()
  73.  
  74.